<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import Watemark from '@/utils/waterMark.js';
import { sendSock, createWebSocket, closeSock } from '@/utils/socket';

export default {
  name: 'App',
  data() {
    return {};
  },
  computed: {},
  mounted() {
    // Watemark.set('膏珍堂中医');

    // window.addEventListener('beforeunload', this.onBeforeunload);
    // console.log('公共链接');
    // var sendData = {
    //   operate: 'singleChannelSwitch',
    //   index: 2 + 1,
    //   opera: '测试'
    // };
    // sendSock(JSON.stringify(sendData));
    // console.log('-----', sendSock);

    // console.log('124555');
  },
  created() {
    // let that = this;
    // let global_callback = function(msg) {
    //   console.log('websocket的回调函数收到服务器信息：' + msg);
    //   that.$notification('操作成功', 'success', msg);
    //   console.log('收到服务器信息：' + msg);
    // };
    // createWebSocket(global_callback);
  },
  destroyed() {
    window.removeEventListener('beforeunload', this.onBeforeunload);
  },
  methods: {
    onBeforeunload() {
      const { params, query, path } = this.$route;
      const pageInfo = {
        params,
        query,
        path: path !== '/404' ? path : '/archives/formula/index'
      };
      localStorage.setItem('reloadUrl', JSON.stringify(pageInfo));
    }
  },
  init() {
    createWebSocket(this.global_callback);
  },
  // websocket的回调函数，msg表示收到的消息
  global_callback(msg) {
    console.log('websocket的回调函数收到服务器信息：' + msg);
    // this.dialogPay = false;
    this.$notification('操作成功', 'success', msg);
    console.log('收到服务器信息：' + msg);
  },
  // 发送
  getSock() {
    console.log('公共链接');
    var sendData = {
      operate: 'singleChannelSwitch',
      index: 2 + 1,
      opera: '测试'
    };
    sendSock(JSON.stringify(sendData));
  },
  // close关闭
  getClose() {
    closeSock();
  }
};
</script>
<style lang="scss">
/*修改滚动条样式*/
div::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  /**/
}
div::-webkit-scrollbar-track {
  background: rgb(239, 239, 239);
  border-radius: 2px;
}
div::-webkit-scrollbar-thumb {
  background: #bfbfbf;
  border-radius: 10px;
}
div::-webkit-scrollbar-thumb:hover {
  background: #333;
}
div::-webkit-scrollbar-corner {
  background: #179a16;
}
.el-notification__content {
  text-align: start;
}
.ms-drop ul>li{
  line-height: 22px;
}
.ms-parent .ms-choice{
  line-height: 28px;
  height: 28px;
}
</style>
